Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPBUGS-35928: Improve control over PatternFly shared modules used in Console plugins #13992

Merged

Conversation

vojtechszocs
Copy link
Contributor

1. Customize node_modules directories to search when parsing dynamic modules

New ConsoleRemotePlugin option sharedDynamicModuleSettings.modulePaths can be used to customize node_modules directories to search when parsing dynamic modules. If not specified, the list will contain a single entry (as per existing logic):

path.resolve(process.cwd(), 'node_modules')

Taking ODF Console Plugin as an example, their webpack config changes the current work directory to accomodate for different plugin builds:

const processPath = path.resolve(__dirname, `plugins/${PLUGIN}`);
process.chdir(processPath);

However, this breaks the default assumption of vendor packages installed at {process.cwd}/node_modules and ultimately results in tons of dynamic module related warnings like:

<w> No dynamic module found for Button in @patternfly/react-core

To address this issue, plugins can now use the above mentioned option like so:

new ConsoleRemotePlugin({
  sharedDynamicModuleSettings: { modulePaths: [path.resolve(__dirname, 'node_modules')] }
})

2. Discard Console provided PatternFly 4.x shared module metadata when using PF 5+

Older plugins using PatternFly 4.x rely on Console providing the following shared modules at runtime:

  • @patternfly/react-core
  • @patternfly/react-table
  • @patternfly/quickstarts

Newer plugins using PatternFly 5.x do NOT utilize above shared modules. Instead, they share individual PatternFly code bits (components, icons, functions, etc.) via dynamic modules (introduced in #13521).

To improve build performance and allow for smaller production builds, we now discard the Console provided PatternFly 4.x shared module metadata when we detect that the plugin uses PF 5+ (detection is based on @patternfly/react-core dependency).

@openshift-ci openshift-ci bot added component/sdk Related to console-plugin-sdk approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 20, 2024
Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor nit. Take it or leave it :)

Comment on lines 348 to 352
if (basePath) {
acc[pkgName] = getDynamicModuleMap(basePath, indexModule, resolutionField);
}

return acc;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we used an immutable accumulator like this:

Suggested change
if (basePath) {
acc[pkgName] = getDynamicModuleMap(basePath, indexModule, resolutionField);
}
return acc;
return !basePath ? acc : {
...acc,
[pkgName]: getDynamicModuleMap(basePath, indexModule, resolutionField)
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealJon Good idea, I'd personally prefer non-negated variation like

return basePath
  ? { ...acc, [pkgName]: getDynamicModuleMap(basePath, indexModule, resolutionField) }
  : acc;

@vojtechszocs vojtechszocs changed the title Improve control over PatternFly shared modules used in Console plugins OCPBUGS-35928: Improve control over PatternFly shared modules used in Console plugins Jun 21, 2024
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 21, 2024
@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: This pull request references Jira Issue OCPBUGS-35928, which is invalid:

  • expected the bug to target the "4.17.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

1. Customize node_modules directories to search when parsing dynamic modules

New ConsoleRemotePlugin option sharedDynamicModuleSettings.modulePaths can be used to customize node_modules directories to search when parsing dynamic modules. If not specified, the list will contain a single entry (as per existing logic):

path.resolve(process.cwd(), 'node_modules')

Taking ODF Console Plugin as an example, their webpack config changes the current work directory to accomodate for different plugin builds:

const processPath = path.resolve(__dirname, `plugins/${PLUGIN}`);
process.chdir(processPath);

However, this breaks the default assumption of vendor packages installed at {process.cwd}/node_modules and ultimately results in tons of dynamic module related warnings like:

<w> No dynamic module found for Button in @patternfly/react-core

To address this issue, plugins can now use the above mentioned option like so:

new ConsoleRemotePlugin({
 sharedDynamicModuleSettings: { modulePaths: [path.resolve(__dirname, 'node_modules')] }
})

2. Discard Console provided PatternFly 4.x shared module metadata when using PF 5+

Older plugins using PatternFly 4.x rely on Console providing the following shared modules at runtime:

  • @patternfly/react-core
  • @patternfly/react-table
  • @patternfly/quickstarts

Newer plugins using PatternFly 5.x do NOT utilize above shared modules. Instead, they share individual PatternFly code bits (components, icons, functions, etc.) via dynamic modules (introduced in #13521).

To improve build performance and allow for smaller production builds, we now discard the Console provided PatternFly 4.x shared module metadata when we detect that the plugin uses PF 5+ (detection is based on @patternfly/react-core dependency).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@vojtechszocs
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jun 21, 2024
@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: This pull request references Jira Issue OCPBUGS-35928, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.17.0) matches configured target version for branch (4.17.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from yapei June 21, 2024 16:46
@vojtechszocs
Copy link
Contributor Author

/retest

Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@vojtechszocs
Copy link
Contributor Author

/test e2e-gcp-console

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 25, 2024
Copy link
Contributor

openshift-ci bot commented Jun 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: TheRealJon, vojtechszocs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

openshift-ci bot commented Jun 25, 2024

@vojtechszocs: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 0a468b4 into openshift:master Jun 25, 2024
6 checks passed
@openshift-ci-robot
Copy link
Contributor

@vojtechszocs: Jira Issue OCPBUGS-35928: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-35928 has been moved to the MODIFIED state.

In response to this:

1. Customize node_modules directories to search when parsing dynamic modules

New ConsoleRemotePlugin option sharedDynamicModuleSettings.modulePaths can be used to customize node_modules directories to search when parsing dynamic modules. If not specified, the list will contain a single entry (as per existing logic):

path.resolve(process.cwd(), 'node_modules')

Taking ODF Console Plugin as an example, their webpack config changes the current work directory to accomodate for different plugin builds:

const processPath = path.resolve(__dirname, `plugins/${PLUGIN}`);
process.chdir(processPath);

However, this breaks the default assumption of vendor packages installed at {process.cwd}/node_modules and ultimately results in tons of dynamic module related warnings like:

<w> No dynamic module found for Button in @patternfly/react-core

To address this issue, plugins can now use the above mentioned option like so:

new ConsoleRemotePlugin({
 sharedDynamicModuleSettings: { modulePaths: [path.resolve(__dirname, 'node_modules')] }
})

2. Discard Console provided PatternFly 4.x shared module metadata when using PF 5+

Older plugins using PatternFly 4.x rely on Console providing the following shared modules at runtime:

  • @patternfly/react-core
  • @patternfly/react-table
  • @patternfly/quickstarts

Newer plugins using PatternFly 5.x do NOT utilize above shared modules. Instead, they share individual PatternFly code bits (components, icons, functions, etc.) via dynamic modules (introduced in #13521).

To improve build performance and allow for smaller production builds, we now discard the Console provided PatternFly 4.x shared module metadata when we detect that the plugin uses PF 5+ (detection is based on @patternfly/react-core dependency).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

This PR has been included in build openshift-enterprise-console-container-v4.17.0-202406260443.p0.g0a468b4.assembly.stream.el9 for distgit openshift-enterprise-console.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/sdk Related to console-plugin-sdk jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants